#ifndef GRATE_TEST_UTILS_H
#define GRATE_TEST_UTILS_H

#include "grate/dfa.h"

#include <cstdlib>
#include <sstream>
#include <string>
#include "gtest/gtest.h"

static unsigned kSeed = 314159265;

inline int random(int n) {
  return rand_r(&kSeed) % n;
}

using growth_rate::DFAInterface;

namespace growth_rate {
namespace testing {

// Returns a fixed values of size, alphabet size, and
// transitions table values (provided by the caller).
class TableDFA : public DFAInterface {
 public:
  // table is a pointer to int[size * alphabet_size] that holds
  // the transition table by rows. It may be null, if the table won't be
  // accessed later.
  TableDFA(size_t size, uint8_t alphabet_size, int *table = 0)
      : DFAInterface(size, alphabet_size) {
    edges_ = table;
  }

 private:
  void shrink_size(size_t new_size) {
    CHECK_LE(new_size, size_);
    size_ = new_size;
  }
};

}  // namespace testing
}  // namespace growth_rate

#endif  // GRATE_TEST_UTILS_H
